<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.leanModal.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<link rel="stylesheet" href="/js/chosen/chosen.css" />
<title>Untitled Document</title>

<style>
.addstaff{
	display:none;
	}

.attn{
	background-color:#FF8080;	
}
textarea{
	background-color:#E87A75;
}

</style>

<script language="javascript"> 
	$(function() {

		$( "#date_begin" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		$( "#date_end" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		$( "#pay_date" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
		
	});

	function toggle(str) {
		var ele = document.getElementById(str);

		if(ele.style.display == "") {
			ele.style.display = "none";
	  	}
		else {
			ele.style.display = "";
		}
	}
</script>

<script language="javascript">
	function refocus(theid){
		
		if(theid !=""){
			document.getElementById(theid).focus();
			}
		}
	function tickAll(source){
		var currentId = $(source).attr('id');
	
		var id = currentId.split("_");
		var checkBoxId = 'tick_'+id[2];

		if(source.checked){
			$('.' + checkBoxId).prop('checked',true);
		}else{
			$('.' + checkBoxId).prop('checked',false);
		}
	}
</script>
</head>

<body >
<form id = "form1" action="" method="post" enctype="multipart/form-data">
<div style="font-family:Arial, Helvetica, sans-serif" >

<input type = "file" name = "file" ></input>
<input type = "submit" name = "upload" value = "Upload File"></input><br/><br/>
<?php $super = new Model_Payroll_Staffsuper();
      $superComp = new Model_Payroll_Supercomp();
  	  $superMethod = new Model_Payroll_Superpaymethod();
  	  $stDetail = new Model_DbTable_Roster_Stafflogindetail();
  	  $stfInfo = new Model_DbTable_Roster_Staffinfo();
  	  $stList = $stDetail->listStaffByNickName();?>
<?php if($this->superList){?>
<h2>Full Information List</h2>

<table width="1300" border="1" cellspacing="0" cellpadding="5">
  <tr>
    <th scope="col">ID</th>
    <th scope="col">Staff Name</th>
    <th scope="col">Amount</th>
    <th scope="col">Period</th>
    <th scope="col">Super Company</th>
    <th scope="col">Payment Method</th>
    <th scope="col">Detail</th>
  </tr>
  
  <?php $i = 1;
  		
  		$total = 0;
  		?>
  <?php foreach ($this->superList as $k => $v){
  			if($v['super_id_company'] != 'zull' && $v['super_payment_method'] != 'zull'){
  				$superName = $superComp->getSupercomp($v['super_id_company']);
  				$superPay = $superMethod->getSuperpaymethod($v['super_payment_method']);
			?>
  <tr>
  	<td><?php echo $i++;?></td>
  	<td><?php echo $v['first_name']." ".$v['last_name'];?></td>
  	<td><?php echo $v['amount']; $total += $v['amount'];?></td>
  	<td><?php echo $v['start_date']." to ".$v['end_date']; ?><input type = "hidden" name = "start_date" value = "<?php echo $v['start_date']?>"></input><input type = "hidden" name = "end_date" value = "<?php echo $v['end_date']?>"></input></td>
  	<td><?php echo $superName['name_sp'];?></td>
  	<td><?php echo $superPay['title_method'];?></td>
  	<td><?php if($v['super_payment_method'] == 1){
  				echo $v['super_bulk_employee_id'];
  			}elseif($v['super_payment_method'] == 2){
  				echo "BPay No. ".$v['super_bpay_biller_code']." Reference: ".$v['super_bpay_reference'];	
  			}elseif($v['super_payment_method'] == 3){
  				echo "Name: ".$v['super_acc_name']." BSB:".$v['super_acc_bsb']." Account No. ".$v['super_acc_no'];
  			}?>
  	</td>
  </tr>
 
  	<?php }else{?>
  	 <tr>
  	<td><?php echo $i++;?></td>
  	<td><?php echo $v['first_name']." ".$v['last_name'];?></td>
  	<td><?php echo $v['amount']; $total += $v['amount'];?></td>
  	<td><?php echo $v['start_date']." to ".$v['end_date']; ?></td>
	<td colspan = "3">No Super Record, Please Update Personal Info</td>
  </tr>
  	
  	<?php }?>
  <?php }?>
   <tr>
  	<td colspan = "7">Total:<?php echo $total;?></td>
  </tr>
 <?php }?>
</table>
<?php if($this->errorList){?>
<h2>Error List</h2>
<input type = "submit" name = "add_record" value = "Add Record"></input><br/>
<table width="700" border="1" cellspacing="0" cellpadding="5">
  <tr>
    <th scope="col">ID</th>
    <th scope="col">Staff Name</th>
    <th scope="col">Amount</th>
    <th scope="col">Period</th>
  </tr>
	<?php foreach ($this->errorList as $k2 => $v2){?>
	<tr>
		<td bgcolor="#FFFFFF"><select name="staff_name[<?php echo $k2?>]" data-placeholder="Staff Name" class="chzn-select" style="width:200px">
      <option value=""></option>
      <?php foreach($stList as $k3 => $v3) {?>
      <option value="<?=$v3["id"]?>">
        <?=ucwords($v3["ni"])?>
        .
        <?=chr($v3["il"]+64)?> ( <?=ucwords(Model_EncryptHelper::getSslPassword($v3["n"]))?> )
        </option>
      <?php } ?>
    </select></td>
		<td><?php echo $v2['first_name']." ".$v2['last_name'];?></td>	
		<td><?php echo $v2['amount'];?><input type = "hidden" name = "amount[<?php echo $k2?>]" value = "<?php echo $v2['amount']?>"></input></td>
		<td><?php echo $v2['start_date']." To ".$v2['end_date'];?><input type = "hidden" name = "start_date[<?php echo $k2?>]" value = "<?php echo $v2['start_date']?>"></input><input type = "hidden" name = "end_date[<?php echo $k2?>]" value = "<?php echo $v2['end_date']?>"></input></td>
	</tr>
	<?php }?>
</table>
<?php }?>
</div>
<br/><br/>
Paid Date:<input type = "text" name = "pay_date" id = "pay_date"></input>
Password:<input type = "password" name ="password" id = "password"></input>
			<input type = "submit" name = "paid_submit" id = "paid_submit" value = "Paid Submit"></input>
<?php foreach ($this->period as $k4 => $v4){
			$missRecord = array();
			$totalAmt = 0;
			$periodList = $super->listPeriodSuper($v4[0], $v4[1]);
			$i = 1;?>
<h3><a href = "javascript:toggle('dT<?=$k4?>');"><?php echo $v4[0]." ~ ".$v4[1]; ?></a></h3>
			<div id = "dT<?=$k4?>" style="display:none;">
			
			Tick All<input type = "checkbox" id = "tick_all_<?php echo $v4[0]?>" onclick = "tickAll(this)"></input>
			<table width="1300" border="1" cellspacing="0" cellpadding="5">
 				<tr>
   					 <th scope="col">ID</th>
    				 <th scope="col">Staff Name</th>
    				 <th scope="col">Amount</th>
    				 <th scope="col">Period</th>
    				 <th scope="col">Super Company</th>
      				 <th scope="col">Payment Method</th>
    				 <th scope="col">Detail</th>
    				 <th scope="col">Paid Date</th>
    				 <th scope="col">Autherized Staff</th>
  				</tr>
		<?php foreach ($periodList as $key => $value){
				$staffInfo = $stfInfo->getStaffinfo($value['staff_id']);
				if($staffInfo['super_id_company'] && $staffInfo['super_payment_method']){
					$superName = $superComp->getSupercomp($staffInfo['super_id_company']);
  					$superPay = $superMethod->getSuperpaymethod($staffInfo['super_payment_method']);?>
				<tr>
					<td><?php echo $i++?></td>
					<td><?php echo $staffInfo['first_name']." ".$staffInfo['last_name']?></td>
					<td><?php echo $value['amount']?></td>
					<td><?php echo $value['start_date']." ~ ".$value['end_date']?></td>
					<td><?php echo $superName['name_sp']?></td>
					<td><?php echo $superPay['title_method']?></td>
					<td><?php if($staffInfo['super_payment_method'] == 1){
  								echo $staffInfo['super_bulk_employee_id'];
  							  }elseif($staffInfo['super_payment_method'] == 2){
  								echo "BPay No. ".$staffInfo['super_bpay_biller_code']." Reference: ".$staffInfo['super_bpay_reference'];	
  							  }elseif($staffInfo['super_payment_method'] == 3){
  							    echo "Name: ".$staffInfo['super_acc_name']." BSB:".$staffInfo['super_acc_bsb']." Account No. ".$staffInfo['super_acc_no'];
  							  }?></td>
					<td><?php if(empty($value['paid_date'])){?><input type ="checkbox" name = "paid_date[<?php echo $v4[0]?>][<?php echo $value['id'];?>]" value = "<?php echo $value['id']?>" class = "tick_<?php echo $v4[0]?>" onclick = "tickAll(this)"></input><?php }else{ echo $value['paid_date'] ;}?></td>
  				    <td><?php if(empty($value['paid_staff'])){ echo "";?><?php }else{ echo $value['paid_staff'] ;}?></td>
  				    <?php $totalAmt += $value['amount'];?>
				</tr>
				<?php }else{?>
						<?php $missRecord[] = $value;
						      $totalAmt += $value['amount'];?>
					
				<?php }?>
			
<?php 		} ?>
				<?php foreach ($missRecord as $key => $value){
						$staffInfo = $stfInfo->getStaffinfo($value['staff_id']);?>
					<tr>
  						<td><?php echo $i++?></td>
						<td><?php echo $staffInfo['first_name']." ".$staffInfo['last_name']?></td>
						<td><?php echo $value['amount']?></td>
						<td><?php echo $value['start_date']." ~ ".$value['end_date']?></td>
						<td colspan = "5">No Super Record, Please Update Personal Info</td>
  					</tr>
				<?php }?>
			</table>
					<h3>Total Amt:<?php echo $totalAmt?></h3>
			</div>
<?php 	}?>

</form>
  <script src="/js/chosen/chosen.jquery.js" type="text/javascript"></script>
  <script type="text/javascript"> 
    var config = {
      '.chzn-select': {allow_single_deselect:true},
    }
    for (var selector in config) {
      $(selector).chosen(config[selector]);
    }
  </script>


</body>
</html>
